#include"db_table.h"

using namespace std;

namespace uhdpbs {
	namespace db {
		table::table(connection* conn) {
			pdbConnection = conn;

			vRows = row_vector();

			vColumns = string_vector();
			mLabels = string_string_map();
			mTypes = string_fieldtype_map();
		}
		table::~table() {}

		string_vector* table::get_columns() { return &vColumns; }
		string_string_map* table::get_labels() { return &mLabels; }
		string_fieldtype_map* table::get_types() { return &mTypes; }
		connection* table::get_connection() { return pdbConnection; }

		unsigned long table::save() {
			return pdbConnection->save(this);
		}
		unsigned long table::load(string order) {
			return pdbConnection->load(this, order);
		}
		// TODO
		void table::clear() {
			vRows.clear();
		}

		row table::create_new_row() { return this->create_new_row(string_string_map()); }

		row_vector* table::get_rows() {
			return &vRows;
		}
	}
}